<?php

session_start();

class MyDB extends SQLite3 {
	function __construct() {
		$this->open('access.db');
	}
}

$db = new MyDB();

if(!$db) { 
		echo $db->lastErrorMsg();
}

//$key = array_search("start", $_POST['event']); // $key = 2;

echo var_dump($_POST['event']);

//echo "KEY: ".$key;

//for($i=0;$i<sizeof($_POST['event']);$i++) {
	//echo $_POST['event'][$i]."\n";
	parse_str($_POST['event'], $output);
	$date_start = $output['start'];
	$date_end = $output['end'];
	$title = $output['title'];
	if(empty($date_end)) {
		$date_end = $date_start;
	}
	$vacation_sql = "INSERT INTO VACATION (uid, title, date_start, date_end) VALUES ('$_SESSION[uid]', '".$title."', '".$date_start."', '".$date_end."')";
	$results = $db->query($vacation_sql);
//}

?>